//
//  LGCancerPatientTreatCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/7/19.
//  治疗记录

#import "LGCancerPatientTreatCell.h"
@interface LGCancerPatientTreatCell()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *effectTip;
/**   */
@property (nonatomic , strong)UILabel *reportTip;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
@end

@implementation LGCancerPatientTreatCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.titleLabel.text = LGNSString(dataDic[@"treat_title"]);
    self.dateLabel.text = LGNSString(dataDic[@"start_date"]);
    NSArray *syptomArray = dataDic[@"syptoms"];
    NSArray *fileArray = dataDic[@"files"];
    CGFloat syptomL = syptomArray.count>0?viewPix(2):0;
    CGFloat syptomW = syptomArray.count>0?viewPix(84):0;
    [self.effectTip mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(syptomL);
        make.width.equalTo(@(syptomW));
    }];
    self.effectTip.hidden = syptomArray.count>0?NO:YES;
    self.reportTip.hidden = fileArray.count>0?NO:YES;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.type = LGPositionTypeMiddle;
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.effectTip];
    [self.contentView addSubview:self.reportTip];
    [self.contentView addSubview:self.dateLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(28));
        make.top.equalTo(self.contentView).offset(viewPix(6));
        make.bottom.equalTo(self.contentView).offset(-viewPix(6));
    }];
    [self.effectTip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(2));
        make.centerY.equalTo(self.titleLabel);
        make.width.equalTo(@(viewPix(64)));
        make.height.equalTo(@(viewPix(16)));
    }];
    [self.reportTip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.effectTip.mas_right).offset(viewPix(2));
        make.centerY.equalTo(self.titleLabel);
        make.width.equalTo(@(viewPix(64)));
        make.height.equalTo(@(viewPix(16)));
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-viewPix(28));
        make.centerY.equalTo(self.titleLabel);
    }];
}
-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UILabel *)effectTip{
    if(!_effectTip){
        _effectTip = [UILabel lableWithText:@"不良反应" colorString:@"#5E8EF5" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        _effectTip.backgroundColor = [UIColor colorWithString:@"#F0F3FD"];
        _effectTip.cornerRidus = viewPix(8);
    }
    return _effectTip;
}
-(UILabel *)reportTip{
    if(!_reportTip){
        _reportTip = [UILabel lableWithText:@"有报告单" colorString:@"#5E8EF5" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        _reportTip.backgroundColor = [UIColor colorWithString:@"#F0F3FD"];
        _reportTip.cornerRidus = viewPix(8);
    }
    return _reportTip;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#909399" textFont:LGFont(15) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _dateLabel;
}
@end
